﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include <vector>

namespace gcmp
{
    enum class OffsetConnect : int32_t //相邻边的连接方式
    {
        ExtendConnect,   /// 采用延长求交
        ArcConnect,      /// 采用圆弧过渡
        MixConnect       /// 优先采用延长求交，延长求交失败，则采用圆弧过渡
    };

    
    /// \brief  记录多边形中的边的环号和边号
    ///
    struct OffsetCoedgeIndex
    {
        /// 环号
        int m_nLoopIndex;
        /// 边号
        int m_nCoedgeIndex;

        /// 默认构造函数
        OffsetCoedgeIndex() : m_nLoopIndex(-1), m_nCoedgeIndex(-1) {}

        
        /// \brief     构造函数
        ///
        /// \param loopIndex    环序号
        /// \param coedgIndex   边序号
        OffsetCoedgeIndex(int loopIndex, int coedgeIndex) : m_nLoopIndex(loopIndex), m_nCoedgeIndex(coedgeIndex) {}
    };

    /// \brief  偏移前后边号的对应关系类
    ///
    class IOffsetCoedgeMap
    {
    public:
        virtual ~IOffsetCoedgeMap() {}

        
        /// \brief  已知Offset之后的边，求初始边
        ///
        /// \param offsetCoedgeIndex                 Offset之后的边号
        /// \param initCoedgeIndex                   对应的初始边号
        /// \return 存在初始边返回true,否则返回false
        virtual bool GetInitCoedge(const OffsetCoedgeIndex &offsetCoedgeIndex, OffsetCoedgeIndex &initCoedgeIndex) const = 0;

        
        /// \brief  已知初始边，求Offset之后的边
        ///
        /// \param initCoedgeIndex                    Offset之后的边号
        /// \param offsetCoedgeIndex                  对应的Offset边号
        /// \return 存在初始边返回true,否则返回false
        virtual bool GetOffsetCoedge(const OffsetCoedgeIndex &initCoedgeIndex, OffsetCoedgeIndex &offsetCoedgeIndex) const = 0;

    };
}